import {dungeons} from "@/api/data/dungeons";

let dungeonNames = null

export function getDungeons(queryString) {
  let queryList = queryString.split(' ');

  return queryList.reduce((pre, query) => {
    return pre.filter(item => {
      return item.tags.toLowerCase()
          .indexOf(query.toLowerCase()) > -1
    })
  }, dungeons.value)
}

export function checkDungeonName(name){
  if (dungeonNames == null){
    dungeonNames = dungeons.value.map(({value}) => value)
  }
  return dungeonNames.indexOf(name) > -1;
}

